import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/home',
        name: 'Home',
        component: Home,
    },
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/category',
        name: 'Category',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/category.vue')
    },
    {
        path: '/car',
        name: 'Car',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/car.vue')
    },
    {
        path: '/myPage',
        name: 'MyPage',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/myPage.vue')
    },
    {
        path: '/login',
        name: 'Login',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/login/Login.vue')
    },
    {
        path: '/userLogin',
        name: 'UserLogin',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/login/UserLogin.vue')
    },
    {
        path: '/register',
        name: 'Register',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/login/Register.vue')
    },
    {
        path: '/recovery',
        name: 'Recovery',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        children: [
            {
                path: '/',
                name: 'RecoveryIndex',
                component: () => import('../views/recovery/RecoveryIndex.vue')
            },
            {
                path: '/recoverybtn',
                name: 'RecoveryBtn',
                component: () => import('../views/recovery/RecoveryBtn.vue')
            }
        ],
        component: () => import ('../views/recovery/Recovery.vue'),

    },
    {
        path: '/search',
        name: 'Search',
        children: [
            {
                path: "/",
                name: "index",
                component: () => import('../views/search/Search-index.vue'),
            },
            {
                path: "list",
                name: "list",
                component: () => import('../views/search/Search-list.vue'),
            }
        ],
        component: () => import('../views/Search.vue'),
    },
    {
        path: '/detail',
        name: 'Detail',
        component: () => import('../views/Detail.vue')
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
